import java.util.Arrays;

public class Hash {
    public class Node {
        int val;
        Node next;
        public Node(int val){
            this.val = val;
        }
    }


    public static final float LOAD_DEFAULT = 0.75f;

    public Node[] arr = new Node[10];

    public int hashDiZhi(int key){
        int value = key%arr.length;
        return value;
    }
    public int  usedSize = 0;

    public void add(int val){
        if(usedSize/arr.length>=LOAD_DEFAULT){
            arr=grow();
        }
        Node node = new Node(val);
         int value = hashDiZhi(val);
         Node head = arr[value];
         if(head==null){
             arr[value] = node;
             usedSize++;
             return;
         }
         Node cur = head;
         while(cur!=null){
             if(cur.val==val){
                 return;
             }
             cur = cur.next;
         }

         node.next = head;
        arr[value] = node;

      usedSize++;

    }

    public Node[] grow(){
        return Arrays.copyOf(arr,arr.length*2);
    }
}
